Re: RE£º[PHP-DB] How do I do math with a

------=_NextPart_000_0047_01CBFC8D.4CD559F0
Content-Type: text/plain;
charset="gb2312"
Content-Transfer-Encoding: quoted-printable


Thank you for the suggestion. This is the actual query that I =
implemented: Amazing how this works. Ron

SELECT SUM( `impressions_total` ) AS impressions_total , SUM( =
`usage_total` ) AS usage_total FROM (

(

SELECT IF ( SUM( `web_advertisements_our_clients_usage`.`impressions` ) =
, SUM( `web_advertisements_our_clients_usage`.`impressions` ) , 0 ) AS =
impressions_total, IF ( SUM( =
`web_advertisements_our_clients_usage`.`usage` ) , SUM( =
`web_advertisements_our_clients_usage`.`usage` ) , 0 ) AS usage_total =
FROM `web_advertisements_our_clients_usage` WHERE =
`web_advertisements_our_clients_reference` =3D =
$web_advertisements_our_clients_reference AND `month` =3D $stats_month =
AND `year` =3D $stats_year LIMIT 1

) UNION ALL (

SELECT `impressions` AS impressions_total, `usage` as usage_total FROM =
`web_advertisements_our_clients` WHERE `reference` =3D =
$web_advertisements_our_clients_reference LIMIT 1

)

) AS monthly_stats_total;

The Verse of the Day
=A1=B0Encouragement from God=A1=AFs Word=A1=B1
http://www.TheVerseOfTheDay.info


------=_NextPart_000_0047_01CBFC8D.4CD559F0--
ron.piggott [ So, 17 April 2011 05:23 ] [ ID #2058257 ]
PHP » gmane.comp.php.database » Re: RE£º[PHP-DB] How do I do math with a

Vorheriges Thema: filter search
Nächstes Thema: How do I do math with a UNION ALL